package rmaqlc31.basic;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class JoinMember
 */
@WebServlet("/JoinMember.do")
public class JoinMember extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
		res.setContentType("text/html; charset=UTF-8");
		PrintWriter out = res.getWriter();
		
		out.print("<html>");
		out.print("<head><title>회원가입</title></head>");
		out.print("<body><h1>회원가입</h1>");
		out.print("<form name='user' method='post'>");
		out.print("<div>아이디<input type='text' name='userId'></div>");
		out.print("<div>비밀번호<input type='password' name='userPwd'></div>");
		out.print("<div>비밀번호 확인<input type='password' name='userRepwd'></div>");
		out.print("<div>이름<input type='text' name='userName'></div>");
		out.print("<div>전자우편<input type='address' name='userAddr'></div>");
		out.print("<div><button type='submit'>입력완료</button>");
		out.print("<button type='reset'>다시입력</button></div>");
		out.print("</form>");
		out.print("</body>");
		out.print("</html>");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
		res.setContentType("text/html; charset=UTF-8");
		PrintWriter out = res.getWriter();
		
		req.setCharacterEncoding("UTF-8");
		
		String userId = req.getParameter("userId");
		String userPwd = req.getParameter("userPwd");
		String userRepwd = req.getParameter("userRepwd");
		String userName = req.getParameter("userName");
		String userAddr = req.getParameter("userAddr");
		
		out.print("<html>");
		out.print("<head><title>회원정보</title></head>");
		out.print("<body>");
		out.print("<h1>회원정보</h1>");
		out.print("<p>아이디 : "+userId+"<br>");
		out.print("비밀번호 : "+userPwd+"<br>");
		out.print("이름 : "+userName+"<br>");
		out.print("전자우편 : "+userAddr+"<br></p>");
		out.print("</body>");
		out.print("</html>");
		
	}

}
